package com.weibo4terios.util;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;

import com.weibo.net.WeiboParameters;

/**
 * SaveParame.java 2012-10-29 下午6:15:49
 * 
 * @author Wang Tengrui
 */
public class SaveParam {

	/**
	 * 保存登录信息
	 * 
	 */
	public static void saveNowUser(Context context, Bundle values) {
		SharedPreferences sharedPreferences = context.getSharedPreferences("NowUser", Activity.MODE_PRIVATE);
		sharedPreferences.edit().putString("uid", values.getString("uid")).putString("access_token", values.getString("access_token")).putString("expires_in", values.getString("expires_in")).putString("expires_date", values.getString("expires_date")).commit();// 提交
		Log.i("SaveParam", "saveNowUser");
	}

	/**
	 * 获取登录用户的信息
	 */
	public static WeiboParameters getNowUser(Context context) {
		SharedPreferences sharedPreferences = context.getSharedPreferences("NowUser", Activity.MODE_PRIVATE);
		WeiboParameters nowUserParameters = new WeiboParameters();
		nowUserParameters.add("uid", sharedPreferences.getString("uid", null));
		nowUserParameters.add("access_token", sharedPreferences.getString("access_token", null));
		nowUserParameters.add("expires_in", sharedPreferences.getString("expires_in", null));
		nowUserParameters.add("expires_date", sharedPreferences.getString("expires_date", null));
		Log.i("SaveParam", "getNowUser");
		return nowUserParameters;
	}
}
